package com.woke.adapter;

import java.util.ArrayList;
import java.util.List;

import com.zhongcai.online.R;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

public class Homeninebuttonadter extends BaseAdapter{
	private LayoutInflater mInflater;
	private List<String> list ;
	private int screenWidth;
	private int[] mDrawables;

	public Homeninebuttonadter(LayoutInflater minflater,ArrayList<String> ninelist, int screenWidth, int[] mDrawables) {
		this.mInflater = minflater;
		this.list = ninelist;
		this.screenWidth = screenWidth;
		this.mDrawables = mDrawables;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}
	
	class Holder {
		ImageView mImage_icon;
		TextView mText_time;
		RelativeLayout mRela_k;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		Holder holder = null;
		if(convertView == null){
			holder = new Holder();
			convertView = mInflater.inflate(R.layout.item_adapter_homenine, null);
			holder.mImage_icon = (ImageView) convertView.findViewById(R.id.item_image_homenine);
			holder.mText_time = (TextView) convertView.findViewById(R.id.item_text_homenine);
			holder.mRela_k = (RelativeLayout) convertView.findViewById(R.id.item_relayout_homenine);
			LayoutParams params = holder.mRela_k.getLayoutParams();
			params.height = screenWidth / 3;
			params.width = screenWidth / 2;
			holder.mRela_k.setLayoutParams(params);
			convertView.setTag(holder);
		}else{
			 holder = (Holder) convertView.getTag();
		}
		holder.mText_time.setText(list.get(position));
		holder.mImage_icon.setImageResource(mDrawables[position]);
		return convertView;
	}

}
